package com.example.demo.thread;

/**
 * @Author: liull
 * @Description:
 * @Date: Created in 15:28 2020/4/4
 * @Modified By:
 */
public class Join {
    static class ThreadA implements Runnable {
        @Override
        public void run() {
            try {
                System.out.println("我是⼦线程，我先睡⼀秒");
                Thread.sleep(1000);
                System.out.println("我是⼦线程，我睡完了⼀秒");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(new ThreadA());
        thread.start();
//        thread.join();// 等thread执行完成进入terminated再执行主线程方法
        //        Thread.sleep(2000);
        System.out.println("如果不加join⽅法，我会先被打出来，加了就不⼀样了,因为我是主线程方法");
    }
}
